<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>body切换颜色</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <style>
    	*{margin: 0;padding: 0;}
    	#color{
    		display: none;
    		width: 30%;
    	}
    	@media(max-width: 800px){
    		button{
    			width: 100%;
    		}
    	}
    </style>
</head>
<body>
<form action="">
    <input type="button" onclick="col('red')" value="红色">
    <input type="button" onclick="col('yellow')" value="黄色">
    <input type="button" onclick="col('blue')" value="蓝色">
    <input type="button" id="d" onclick="aa()" value="点击设置自定义颜色">
    <input type="color" id="color" onchange="aa()" value="#ffffff">
</form>
<script>
    var body  = document.querySelector('body');
    var on = document.getElementById('color')
    function col(a){
        body.style.background = a;
        on.style.display = 'none';
    }
    function aa(){
        body.style.background = on.value;
        on.style.display = 'inline-block';
    }
</script>
</body>
</html>